package atguigu.jdbc;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;  
  
import java.sql.Connection;  
import java.sql.SQLException;  
  
public class HiveConnectionPool {  
    private static HikariDataSource ds;  
  
    static {  
        HikariConfig config = new HikariConfig();  
        config.setJdbcUrl("jdbc:hive2://10.23.114.104:10001/");
        config.setUsername("lims_bind");
        config.setPassword("FfA24s*85M");
        config.addDataSourceProperty("driverClassName", "org.apache.hive.jdbc.HiveDriver");  
        config.setMaximumPoolSize(10);  
        config.setMinimumIdle(5);  
        config.setConnectionTimeout(30000);  
        config.setIdleTimeout(600000);  
        config.setMaxLifetime(1800000);  
  
        ds = new HikariDataSource(config);  
    }  
  
    public static Connection getConnection() throws SQLException {  
        return ds.getConnection();  
    }  
  
    public static void close() {  
        if (ds != null) {  
            ds.close();  
        }  
    }  
}